import { createSlice } from "@reduxjs/toolkit"
// payload ts类型
import type { PayloadAction } from "@reduxjs/toolkit"

interface Istate {
	count: number
	derection?: "left" | "right" | "top" | "down"
}

const initialState: Istate = {
	count: 0,
}

const conterSlice = createSlice({
	name: "Counter",
	initialState,
	reducers: {
		incrementAction(state, { payload }: PayloadAction<number>) {
			state.count += payload
		},
	},
})
export const { incrementAction } = conterSlice.actions
export default conterSlice.reducer
